package com.system.employee.controller;

import com.system.employee.bean.Employee;
import com.system.employee.bean.OptionBean;
import com.system.employee.bean.OptionsBean;
import com.system.employee.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 林
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    @PostMapping("/save")
    public boolean saveHandle(@RequestBody Employee employee){
        return employeeService.saveEmployee(employee);
    }

    @DeleteMapping("/del/{id}")
    public boolean deleteHandle(@PathVariable("id") int id){
        return employeeService.removeEmployeeById(id);
    }

    @PutMapping("/update")
    public boolean updateHandle(@RequestBody Employee employee){
        return employeeService.modifyEmployee(employee);
    }

    @GetMapping("/get/{id}")
    public Employee getHandle(@PathVariable("id") int id){
        return employeeService.getEmployeeById(id);
    }

    @GetMapping("/get/list")
    public List<Employee> listHandle(){
        return employeeService.listAllEmployees();
    }

    @GetMapping("/get/listAllByDepartmentId/{departmentById}")
    public List<Employee> listAllByDepartmentId(@PathVariable("departmentById") int departmentById){
        return employeeService.getListAllByDepartmentId(departmentById);
    }
    @GetMapping("/get/doctorList")
    public List<Employee> getDoctorList(){
        return employeeService.getDoctorList();
    }

    @GetMapping("/get/doctorOptions")
    public OptionsBean<OptionBean> getDoctorOptions(){
        return employeeService.getDoctorOptions();
    }

}
